package com.itcat.controller;

import com.itcat.api.mysql.PmsProductAttributeApi;
import com.itcat.common.CommonPage;
import com.itcat.common.CommonResult;
import com.itcat.mysql.param.PageParam;
import com.itcat.mysql.pojo.PmsProductAttribute;
import com.itcat.mysql.pojo.PmsProductCategoryAttributeRelation;
import com.itcat.service.PmsProductAttributeService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Jerry Broker
 * @project_name rainbow-mall
 * @create 2022-04-03 21:19
 */
@RestController
@RequestMapping("/productAttribute")
public class PmsProductAttributeController {

    @Autowired
    private PmsProductAttributeService pmsProductAttributeService;

    /**
     * 根据分类查询属性列表或参数列表
     * @param cid
     * @param pageParam
     * @param type
     * @return
     */
    @GetMapping("/list/{cid}")
    public CommonResult list(@PathVariable("cid") Integer cid, PageParam pageParam, Integer type){
        CommonPage<PmsProductAttribute> page = pmsProductAttributeService.list(cid, pageParam, type);
        return  CommonResult.success(page);

    }

    /**
     * 回显分类的属性
     * @param productCategoryId
     * @return
     */
    @GetMapping("/attrInfo/{productCategoryId}")
    public CommonResult attrInfo(@PathVariable("productCategoryId") Integer productCategoryId){
        List map = pmsProductAttributeService.attrInfo(productCategoryId);

        return  CommonResult.success(map);
    }
}
